/**
 * Created by Sean on 2017/5/9.
 */
class Thread1 extends Thread {
    private String threadName; // 用于标示不同的线程

    public Thread1(String threadName) {
        this.threadName = threadName;
    }

    @Override
    public void run() {
        super.run();
        for (int i = 0; i < 5; i++) {
            System.out.println(threadName + "运行，此时的 i = " + i);
            try {
                sleep((int) Math.random() * 10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

public class Main1 {

    public static void main(String[] args) {
        Thread1 thread1 = new Thread1("我是在A线程中");
        Thread1 thread2 = new Thread1("我是在B线程中");
        thread1.start();
        thread2.start();
    }
}
